var okyumLoader = {
	// 通用js
	commonScripts : [['/pages/scripts/lib/jquery/jquery.js', '20091229'],
			['/pages/scripts/lib/jquery/jquery.simplemodal.js', '20091229']],

	// 非通用js
	scripts : {
	},

	// 通用css
	commonStyles : [['/pages/styles/common.css', '20091229']],
	
	// 非通用css
	styles : {
	},

	// 包含一个js
	includeScript : function(array) {
		document.write('<script type="text/javascript" charset="utf-8" src="'
				+ array[0] + '?' + array[1] + '"></script>');
	},

	// 包含一个css
	includeStyle : function(array) {
		document.write('<link rel="stylesheet" type="text/css" href="' + array[0]
				+ '?' + array[1] + '" />');
	},

	// 包含所有通用的js
	includeCommonScripts : function() {
		for (var i = 0; i < this.commonScripts.length; i++) {
			this.includeScript(this.commonScripts[i]);
		}
	},
	
	// 包含所有通用的css
	includeCommonStyles : function() {
		for (var i = 0; i < this.commonStyles.length; i++) {
			this.includeStyle(this.commonStyles[i]);
		}
	},
	
	// 包含参数中指定的js和css
	includeDynamic : function() {
		var scriptElements = document.getElementsByTagName("script");
		for (var i = 0; i < scriptElements.length; i++) {
			var s = scriptElements[i];
			if (s.src && s.src.match(/loader\.js(\?.*)?$/)) {
				// 加载参数中指定的js
				var scriptParams = s.src.match(/&script=([a-zA-Z,]*)/);
				if (scriptParams) {
					var paramArray = scriptParams[1].split(',')
					for (var j = 0; j < paramArray.length; j++) {
						var str = paramArray[j];
						if (this.scripts[str]) {
							this.includeScript(this.scripts[str]);
						}
					}
				}
				
				// 加载参数中指定的css
				var cssParams = s.src.match(/&css=([a-zA-Z,]*)/);
				if (cssParams) {
					var paramArray = cssParams[1].split(',')
					for (var j = 0; j < paramArray.length; j++) {
						var str = paramArray[j];
						if (this.styles[str]) {
							this.includeStyle(this.styles[str]);
						}
					}
				}
				
				break;
			}
		}
	},

	includeAll : function() {
		this.includeCommonScripts();
		this.includeCommonStyles();
		this.includeDynamic();
	}
};

okyumLoader.includeAll();
